home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 3 / Cream of the Crop 3.iso / utility / clustr.zip / CLUSTER.BAS next >
BASIC Source File  |  1993-11-19  |  32KB  |  993 lines

  1. '*****************************CLUSTER.BAS*******************************
  2. '
  3. 'I'm Getting a 535 MB Hard drive. Want to know how to use FDISK.EXE to
  4. 'partition it most effectively. Most files are NOT 8K (8192 bytes) long
  5. 'and only one file fits per cluster. Using 8K Clusters on a 100 MB drive
  6. 'gave me 12 MB (sic) of "Slack Space"; Using MS-DOS 5.0 (or greater)
  7. 'with FDISK.EXE and reformating the drive gave me 2 K Clusters and regained
  8. '6 MegaBytes of disk space... Worth doing.... If you are the fearless type
  9. 'and have really and truly backed up your hard drive to TWO tapes and run
  10. 'the tape compare on BOTH of them.
  11. '
  12. 'John De Palma on CompuServe 76076,571
  13. '11/12/93
  14. 'WOW!!!! 66 K executable file size.... This is a job for PDQ!
  15. '
  16. 'Ouch!!!
  17. 'can't compile with PDQ because of:
  18. 'Exteral error with Setborder because it was in BORDER2.BAS with a
  19. 'different TYPE declaration, putting it here makes it work!, now to fix
  20. 'the next two errors
  21. 'B$USNG error "Print Using"  <--- fixed by using FUsing Function
  22. 'B$POW4 error "Raising a number to a power"  <--- fixed by using Power Function
  23. 'fixed the SETBORDER ERROR had to change the USER DEFINED TYPE to the
  24. 'PDQ one and make it a sub here, though not sure that was necessary
  25. '11/13/93
  26. 'Ouch...ouch ouch!! TAB() doesn't work right with PDQ, had to excise
  27. 'all tabs and substitute spaces...
  28. '
  29. '11/16/93
  30. 'Call to Ethan Winer, QuickPAK library doesn't contain CALL INTERRUPT...
  31. 'Ethan called  back...
  32. 'Now to learn about LIB.EXE...., ugh!
  33. '11/17/93
  34. 'NOW Have ALL the PDQ.QLB routines merged into PDQPRO.QLB which is loaded
  35. 'with this file. It works. The errors so far are:
  36. '
  37. '1.     Mistyped Function names in DECLARE.BAS (not my fault)
  38. '       get "program undefined" error
  39. '
  40. '2.     Forgetting to LOAD Basic SUBS and FUNCTIONS that are NOT
  41. '       QuickPAK Assembly functions, get "program undefined" error
  42. '
  43. 'So far so good... no real problems, lots of typos, but what the hey...
  44.  
  45. 'Declarations and non executable code follows
  46.  
  47. '$INCLUDE: 'c:\qb45\pdq\PDQDECL.BAS'    'this is PDQ's INCLUDE file
  48. DEFINT A-Z               'absolutely essential for the assembly language calls!
  49. CONST False = 0, True = -1
  50. CONST row% = 2
  51.  
  52. 'QuickPak Routines                  'all of these can be done in QuickBASIC
  53.  
  54. DECLARE FUNCTION GetDrive% ()
  55. DECLARE FUNCTION GetDir$ (Drive$)
  56. DECLARE FUNCTION ASCII% (Work$)
  57. DECLARE FUNCTION Exist% (FileName$)
  58. DECLARE SUB BLPrint (LPTNo, X$, ErrCount)    'LPRINT doesn't work in PDQ
  59.  
  60. 'DECLARE SUB Pause (Ticks%)             'a dup definition, in PDQ's declare file
  61.  
  62. 'name of this next function was MISPELLED in QuickPAK's DECLARE.BAS
  63. 'got a Program undefined error... real problem to figure out
  64. 'good lesson "trust no one, suspect everyone, shoot on sight!"
  65. 'check spelling first with that error
  66. 'DECLARE FUNCTION ParseString$ (CurPos%, Work$, Delimit$)
  67.  
  68.  
  69. ' Functions for ReadText SUB            'this is from READ.COM
  70.   DECLARE FUNCTION KeyCode% ()
  71.  
  72. ' Subprograms fir ReadText SUB
  73.   DECLARE SUB FileRead (FileName$, LineCount%, a$())
  74.   DECLARE SUB ParseWords (FileName$, Drive$, File$, Ext$)
  75.  
  76. ' Dimension string array
  77. '  DIM a$(1 TO 2000)
  78.  
  79. TYPE disks
  80.         SectorsPerCluster AS INTEGER
  81.         BytesPerSector AS INTEGER
  82.         clustersPerDrive AS LONG
  83.         AvailableClusters AS LONG
  84.         availableBytes AS LONG
  85. END TYPE
  86.  
  87. 'SUBs & FUNCTIONs in CLUSTER.BAS
  88.  
  89. DECLARE SUB SetBorder (ColrByte%)
  90. DECLARE SUB ScreenOne (row2%, col2%)
  91. DECLARE SUB ScreenOpen ()
  92. DECLARE SUB GetDiskFreeSpace (Drive$, ClusterSize%)
  93. DECLARE SUB ReadText (FileName$)
  94. DECLARE SUB ParseDisk (Mega%, ClusterSize%, Drive$)
  95. DECLARE SUB ToPrint (Mega%, ClusterSize%)
  96. DECLARE FUNCTION Choice% (YN$)
  97. DECLARE SUB WannaPrint (Mega%, ClusterSize%)
  98. DECLARE SUB WhereIsHelpFile (FileName$)
  99. DECLARE FUNCTION Center% (text$)
  100.  
  101. 'executable code starts here
  102.  
  103. OPTION BASE 1                      'for the array of disk drive names
  104. SCREEN 0
  105. WIDTH 80
  106. COLOR 15, 1
  107. CLS
  108. FileName$ = "CLUSTER.DOC"
  109. CALL WhereIsHelpFile(FileName$)
  110. 'STOP
  111.  
  112.  
  113. 'this is a PDQ function to do exponents
  114. 'in QuickBASIC it would be KiloByte&= 2^10
  115. KiloByte& = Power2&(10)
  116. MegaByte& = Power2&(20)
  117. EightKCluster& = Power2&(13)
  118. FourKCluster& = Power2&(12)
  119. TwoKCluster& = Power2&(11)
  120.  
  121. CALL ScreenOpen
  122. CALL SetBorder(13)
  123. 'gets information about your C: Drive
  124. 'STOP                            'like STOP better than BreakPoint
  125.  
  126. Drive$ = CHR$(GetDrive%) + ":"
  127. CALL GetDiskFreeSpace(Drive$, ClusterSize%)
  128. 'PRINT ClusterSize%
  129. text$ = "Do you FIRST want to read the text file???"
  130. LOCATE row% + 16, Center(text$)
  131.                                                                     
  132.                                                        
  133. COLOR 11, 1
  134. PRINT text$
  135. text$ = "PRESS 'Y' for YES if you do"
  136. LOCATE row% + 17, Center(text$)
  137. PRINT text$
  138. text$ = "-OR- any other key for NO to RUN the PROGRAM..."
  139. LOCATE row% + 20, Center(text$)
  140. PRINT text$
  141.  
  142. COLOR 7, 0
  143. text$ = "  "
  144. LOCATE row% + 18, Center(text$), 1, 4, 7
  145. PRINT text$
  146. LOCATE row% + 18, Center(text$)
  147.  
  148. 'STOP
  149. IF Choice(YN$) THEN
  150.      CALL ReadText(FileName$)
  151. ELSE
  152.  
  153. END IF
  154. AnotherDrive:
  155. CALL SetBorder(14)
  156. COLOR 15, 1
  157. CLS
  158. LOCATE , , 0
  159. text$ = "Cluster Size versus Hard Drive Size"
  160. LOCATE row%, Center(text$), 0
  161. COLOR 11, 0: PRINT text$
  162. text$ = " -THINGS- You Need to Know about Clusters... "
  163. LOCATE row% + 1, Center(text$)
  164. COLOR 11, 2: PRINT text$
  165. text$ = " Or... How to Make 2K Clusters with BIG Hard Drives "
  166. COLOR 11, 3: LOCATE row% + 2, Center(text$)
  167. PRINT text$
  168. 'STOP
  169. COLOR 15, 1
  170. LOCATE row% + 4, 10
  171. PRINT "One KiloByte equals:         "; KiloByte&; " bytes"
  172. LOCATE row% + 5, 10
  173. PRINT "One MegaByte equals:    ";
  174. 'using PDQ function note IMAGE$ format for commas
  175. PRINT FUsing$(STR$(MegaByte&), "#########,")
  176. LOCATE row% + 7, 10
  177. PRINT "Eight K Cluster equals: "; EightKCluster&; " bytes"
  178. LOCATE row% + 8, 10
  179. PRINT "Four  K Cluster equals: "; FourKCluster&
  180. LOCATE row% + 9, 10
  181. PRINT "Two   K Cluster equals: "; TwoKCluster&;
  182.  
  183. LOCATE row% + 11, 10
  184. PRINT "Eight K Clusters per MB is: "; MegaByte& / EightKCluster&; " Number"
  185. LOCATE row% + 12, 10
  186. PRINT "Four  K Clusters per MB is: "; MegaByte& / FourKCluster&
  187. LOCATE row% + 13, 10
  188. PRINT "Two  K  Clusters per MB is: "; MegaByte& / TwoKCluster&
  189.  
  190. 'use integer divisor to round down
  191.  
  192. LOCATE row% + 15, 10
  193. PRINT "Max Hard disk size with 2 MB clusters is: "; : COLOR 11, 1: PRINT 65518 \ (MegaByte& / TwoKCluster&); : COLOR 15, 1: PRINT " MB"
  194. COLOR 15, 1
  195. LOCATE row% + 16, 10
  196. PRINT "Max Hard disk size with 4 MB clusters is: "; 65518 \ (MegaByte& / FourKCluster&); " MB"
  197. LOCATE row% + 17, 10
  198. PRINT "Max Hard disk size with 8 MB clusters is: "; 65518 \ (MegaByte& / EightKCluster&); " MB"
  199.  
  200. text$ = " Your " + Drive$ + " Drive Cluster Size is: >>" + STR$(ClusterSize%) + " << "
  201. LOCATE row% + 14, Center(text$)
  202. COLOR 15, 4: PRINT " Your " + Drive$ + " Drive Cluster Size is: >>";
  203. COLOR 15 + 16, 4: PRINT STR$(ClusterSize%);
  204. COLOR 15, 4: PRINT " << "
  205.  
  206. text$ = "View another Drive Cluster Statistics?..."
  207. LOCATE row% + 19, Center(text$)
  208. COLOR 14, 6: PRINT text$
  209. text$ = "PRESS 'Y' for YES, -or- another Key to Go on...."
  210. LOCATE row% + 21, Center(text$)
  211. PRINT text$;
  212. COLOR 7, 0
  213. text$ = "  "
  214. LOCATE row% + 20, Center(text$), 1, 4, 7
  215. PRINT text$
  216. LOCATE row% + 20, Center(text$)
  217.  
  218. 'STOP
  219. WHILE INKEY$ <> "": WEND                'clear keyboard
  220. 'Again:
  221. IF Choice(YN$) THEN
  222. COLOR 15, 3
  223. CLS
  224. SetBorder (11)
  225. CALL ScreenOpen
  226. 'STOP
  227. text$ = "What Drive Statistics do you Want???"
  228. LOCATE row% + 16, Center(text$)
  229. COLOR 11, 1
  230. PRINT text$
  231. text$ = " PRESS the drive LETTER,   ie: 'A' or 'B' or 'C'.... "
  232. LOCATE row% + 18, Center(text$)
  233. PRINT text$
  234.  
  235. COLOR 7, 0
  236. text$ = "  "
  237. LOCATE row% + 18, Center(text$), 1, 4, 7
  238. PRINT text$
  239. LOCATE row% + 18, Center(text$)
  240. Drive$ = INPUT$(1)
  241. LOCATE , , 0
  242. Drive$ = UCASE$(Drive$)
  243. PRINT Drive$
  244. 'didn't put in error checking in case you entered a drive you don't have
  245. 'just to see what happens, all that happens is you get a zero
  246. 'cluster size but some weird number for total number of clusters on
  247. 'that non existant drive...
  248. CALL GetDiskFreeSpace(Drive$, ClusterSize%)
  249. PAUSE (18)
  250. COLOR 15, 4
  251. text$ = "PRESS any key to CONTINUE the PROGRAM..."
  252. LOCATE row% + 20, Center(text$)
  253. PRINT text$
  254.  
  255. WHILE INKEY$ <> "": WEND                'clear keyboard
  256. DO
  257. kee$ = INKEY$
  258. LOOP UNTIL LEN(kee$)                    'pause
  259.  
  260. GOTO AnotherDrive
  261.  
  262. ELSE
  263.  
  264. END IF
  265.  
  266. 'LOCATE , , 1
  267. TryAgain:
  268. CALL SetBorder(11)
  269. CALL ScreenOne(row2, col2)
  270. LOCATE row2, col2, 1, 4, 7
  271. COLOR 7, 0
  272. 'STOP
  273. INPUT "", Mega$
  274. Mega% = VAL(Mega$)
  275. IF Mega$ = "" THEN
  276. SetBorder (0)
  277. LOCATE , , 1, 6, 7
  278. END
  279. ELSEIF Mega% <= 0 OR Mega% > 2921 THEN
  280. BEEP
  281. GOTO TryAgain
  282. ELSE
  283. END IF
  284. 'PRINT Mega%
  285. CALL SetBorder(4)
  286. CALL ParseDisk(Mega%, ClusterSize%, Drive$)
  287. 'GOTO Again
  288.  
  289. 'This file was last compiled with:
  290. 'BC C:\QB45\PDQ\CLUSTRP2.BAS  /o;
  291. 'LINK CLUSTRP2+
  292. '     C:\QB45\PDQ\_CPRINT+
  293. '     /nod /noe /packcode /far
  294. '
  295. '     nul
  296. '     C:\QB45\PDQ\PRO C:\QB45\PDQ\PDQ
  297. '
  298. '------------------     00:17 AM    11/17/93   -----------------------------
  299.  
  300. 'This file was last compiled with:
  301. 'BC C:\QB45\PDQ\CLUS_PDQ.BAS  /o;
  302. 'LINK CLUS_PDQ+
  303. '     C:\QB45\PDQ\_CPRINT+
  304. '     /nod /noe /packcode /far /ex
  305. '
  306. '     nul
  307. '     C:\QB45\PDQ\PRO C:\QB45\PDQ\PDQ
  308.  
  309. 'This file was last compiled with:
  310. 'BC C:\QB45\PDQ\CLUSTER.BAS  /o;
  311. 'LINK CLUSTER+
  312. '     C:\QB45\PDQ\_CPRINT+
  313. '     /nod /noe /packcode /far
  314. '
  315. '     nul
  316. '     C:\QB45\PDQ\PRO C:\QB45\PDQ\PDQ
  317.  
  318. 'This file was last compiled with:
  319. 'BC C:\QB45\PDQ\CLUSTER.BAS  /o;
  320. 'LINK CLUSTER+
  321. '     C:\QB45\PDQ\_CPRINT+
  322. '     /nod /noe /packcode /far /ex
  323. '
  324. '     nul
  325. '     C:\QB45\PDQ\PRO C:\QB45\PDQ\PDQ
  326.  
  327. FUNCTION Center (text$)
  328. Center = 41 - LEN(text$) \ 2
  329. END FUNCTION
  330.  
  331. FUNCTION Choice (YN$)
  332.  
  333. YN$ = INPUT$(1)
  334. YN$ = UCASE$(YN$)
  335. PRINT YN$
  336. LOCATE , , 0
  337. IF YN$ = "Y" THEN
  338. Choice = True
  339. ELSE
  340. Choice = False
  341. END IF
  342. END FUNCTION
  343.  
  344.     SUB FileRead (FileName$, LineCount%, a$()) STATIC
  345.         FileNumber% = FREEFILE
  346.         OPEN FileName$ FOR INPUT AS FileNumber%
  347.         FOR i% = LBOUND(a$) TO UBOUND(a$)
  348.             LINE INPUT #FileNumber%, a$(i%)
  349.             LineCount% = i%
  350.             IF EOF(FileNumber%) THEN
  351.                 EXIT FOR
  352.             END IF
  353.         NEXT i%
  354.         IF NOT EOF(FileNumber%) THEN
  355.             LineCount% = True                  'set EOF to -1 and avoids error
  356.         END IF
  357.     END SUB
  358.  
  359. SUB GetDiskFreeSpace (Drive$, ClusterSize%)
  360.   ' from John C Craig's Toolbox
  361.  
  362. DIM disk AS disks
  363. 'STOP
  364.         DIM reg AS RegType
  365.         IF Drive$ <> "" THEN
  366.             Drive% = ASC(UCASE$(Drive$)) - 64
  367.         ELSE
  368.             Drive% = 0
  369.         END IF
  370.         IF Drive% >= 0 THEN
  371.             reg.DX = Drive%
  372.         ELSE
  373.             reg.DX = 0
  374.         END IF
  375.         reg.AX = &H3600
  376.         CALL Interrupt(&H21, reg)
  377.         disk.SectorsPerCluster = reg.AX
  378.         disk.BytesPerSector = reg.CX
  379.         IF reg.DX >= 0 THEN
  380.             disk.clustersPerDrive = reg.DX
  381.         ELSE
  382.             disk.clustersPerDrive = reg.DX + 65536
  383.         END IF
  384.         IF reg.BX >= 0 THEN
  385.             disk.AvailableClusters = reg.BX
  386.         ELSE
  387.             disk.AvailableClusters = reg.BX + 65536
  388.         END IF
  389.         disk.availableBytes = disk.AvailableClusters * reg.AX * reg.CX
  390.    
  391.     COLOR 14, 6
  392.     'if I use ClusterSize% to print here it doesn't work
  393.    
  394.     ClusterSize% = disk.SectorsPerCluster * disk.BytesPerSector
  395.     text$ = " Drive Bytes per CLUSTER  »»»" + STR$(disk.SectorsPerCluster * disk.BytesPerSector)
  396.     LOCATE row% + 8, Center(text$)
  397.    
  398.     PRINT text$
  399.    
  400.     text$ = " This DRIVE is »»» " + Drive$
  401.     LOCATE row% + 9, Center(text$)
  402.     COLOR 11, 0
  403.     PRINT text$
  404.     COLOR 14, 1
  405.     LOCATE row% + 11, 20
  406.     PRINT "Total Clusters on drive     "; disk.clustersPerDrive
  407.     LOCATE row% + 12, 20
  408.     PRINT "Available Clusters          "; disk.AvailableClusters
  409.     LOCATE row% + 13, 20
  410.    
  411.     PRINT "Available Bytes          "; 'disk.availableBytes
  412.     PRINT FUsing$(STR$(disk.availableBytes), "#############,")
  413.    
  414.     LOCATE row% + 14, 20
  415.     DiskSize2& = disk.BytesPerSector * disk.clustersPerDrive * disk.SectorsPerCluster
  416.     PRINT "Total Disk Size          ";
  417.     PRINT FUsing$(STR$(DiskSize2&), "##############,")
  418.  
  419.  
  420. END SUB
  421.  
  422. FUNCTION KeyCode% STATIC
  423.         DO
  424.             k$ = INKEY$
  425.         LOOP UNTIL k$ <> ""
  426.         KeyCode% = CVI(k$ + CHR$(0))
  427.  
  428. END FUNCTION
  429.  
  430. SUB ParseDisk (Mega%, ClusterSize%, Drive$) STATIC
  431. COLOR 15, 2
  432. CLS
  433. LOCATE , , 0
  434. DIM Drive$(24)
  435. FOR num = 1 TO 24
  436.         Drive$(num) = CHR$(66 + num)
  437. '       PRINT Drive$(num)
  438. NEXT num
  439.  
  440. 'ClusterSize% = 1024
  441.  
  442. SELECT CASE Mega%
  443.         CASE 1 TO 127
  444.                
  445.                         SELECT CASE ClusterSize%
  446.                         CASE 512 TO 1024
  447.                         text$ = "DRIVE STATISTICS ON: " + Drive$
  448.                         LOCATE row%, Center(text$)
  449.                         PRINT text$;
  450.  
  451.                         text$ = "You Really don't need my help...."
  452.                         LOCATE row% + 2, Center(text$)
  453.                         PRINT text$;
  454.                         LOCATE row% + 4, Center(text$)
  455.                         PRINT "Think this is a Floppy. Size is: "; STR$(Mega%)
  456.                         LOCATE row% + 6, Center(text$)
  457.                         PRINT "Cluster Size is:"; STR$(ClusterSize%)
  458.  
  459.                         CASE 2048
  460.                         text$ = "DRIVE STATISTICS ON: " + Drive$
  461.                         LOCATE row%, Center(text$)
  462.                         PRINT text$;
  463.                         text$ = "You Really don't need my help...."
  464.                         LOCATE row% + 2, Center(text$)
  465.                         PRINT text$;
  466.                         LOCATE row% + 4, Center(text$)
  467.                         PRINT "Hard Disk Size is: "; STR$(Mega%)
  468.                         LOCATE row% + 6, Center(text$)
  469.                         PRINT "Cluster Size is:"; STR$(ClusterSize%)
  470.                        
  471.                         CASE 4096 TO 8916
  472.                         text$ = "DRIVE STATISTICS ON: " + Drive$
  473.                         LOCATE row%, Center(text$)
  474.                         PRINT text$;
  475.                         text$ = "USE FDISK.EXE with DOS 5.0 or Better...."
  476.                         LOCATE row% + 2, Center(text$)
  477.                         PRINT text$;
  478.                         LOCATE row% + 4, Center(text$)
  479.                         PRINT "Hard Disk Size is: "; STR$(Mega%)
  480.                         LOCATE row% + 6, Center(text$)
  481.                         PRINT "Cluster Size is:"; STR$(ClusterSize%)
  482.                         CASE ELSE
  483.                        
  484.                         text$ = "Uh....Something's WRONG here...."
  485.                         LOCATE row% + 2, Center(text$)
  486.                         PRINT text$;
  487.                         LOCATE row% + 4, Center(text$)
  488.                         PRINT "Hard Disk Size is: "; STR$(Mega%)
  489.                         LOCATE row% + 6, Center(text$)
  490.                         PRINT "Cluster Size is:"; STR$(ClusterSize%)
  491.                         END SELECT
  492.         
  493.          CASE 128 TO 2921
  494.                
  495.                 LOCATE row% - 1, 20
  496.                 PRINT "FOR DRIVE " + Drive$; STRING$(10, 32); "Drive Size in MB"
  497.                 NumberDrives% = Mega% \ 127
  498.                 IF Mega% MOD 127 <> 0 THEN
  499.                         NumberDrives% = NumberDrives% + 1
  500.                 END IF
  501.                 LOCATE row%, 10
  502.                 PRINT STRING$(60, 205)
  503.                 Temp% = Mega%
  504.                
  505.                 FOR n = 1 TO NumberDrives%
  506.                 LOCATE row% + n, 20
  507. 'STOP
  508.                 SELECT CASE Temp%
  509.  
  510.                         CASE IS > 127 + 15
  511.                         DriveSize = 127
  512.                         CASE IS < 127
  513.                                 DriveSize = Temp%
  514.                         CASE 127
  515.                                 DriveSize = 127
  516.                         CASE IS < 127 + 16
  517.                                 DriveSize = 127 - 16 + (Temp% MOD 127)
  518.                         CASE ELSE
  519.                         PRINT Temp%
  520.                         BEEP
  521.                         PRINT "BIG MISTAKE!... probably mine"
  522.                         STOP
  523.                END SELECT
  524.             
  525.                 PRINT "Drive: "; Drive$(n); STRING$(17, 32); DriveSize;
  526.                 Temp% = Temp% - DriveSize
  527.  
  528.                 NEXT n
  529.       
  530.         CASE ELSE
  531.            text$ = "Uh.... The DRIVE Size is: " + STR$(Mega%)
  532.            LOCATE row% + 2, Center(text$)
  533.            PRINT text$
  534.            BEEP
  535. END SELECT
  536. WHILE INKEY$ = "": WEND
  537. 'STOP
  538. CALL WannaPrint(Mega%, ClusterSize%)
  539. CALL SetBorder(0)
  540. LOCATE , , 1, 6, 7
  541. END SUB
  542.  
  543. SUB ParseWords (FileName$, Drive$, File$, Ext$) STATIC
  544. 'this is clumsy, but it seems a fair way to parse a long full path
  545. 'to show a file name
  546.  
  547. ln = LEN(FileName$)
  548.  
  549. ' first get the drive
  550.  
  551. colon = INSTR(FileName$, ":")
  552. IF colon THEN
  553.         Drive$ = LEFT$(FileName$, colon)
  554. END IF
  555.  
  556. ' next erase a final backslash if it exists
  557.  
  558. IF RIGHT$(FileName$, 1) = "\" THEN
  559.         Temp$ = LEFT$(FileName$, ln - 1)
  560.         ln = ln - 1
  561.         ELSE
  562.         Temp$ = FileName$
  563. END IF
  564.  
  565. ' third get the Extension
  566.  
  567. FOR n = ln TO 1 STEP -1
  568.  
  569.         Ext$ = MID$(Temp$, n)
  570.         IF INSTR(Ext$, ".") THEN
  571.         Ext$ = LEFT$(Ext$, 4)
  572.         Temp$ = LEFT$(Temp$, n - 1)
  573.         k = n
  574.         EXIT FOR
  575.         ELSE
  576.         Ext$ = ""
  577.         k = ln           'if there is no extension
  578.         END IF
  579. NEXT n
  580.  
  581. 'fourth get the file name but not more than 8 letters...
  582.  
  583. FOR n = k TO 1 STEP -1
  584.          File$ = MID$(Temp$, n)
  585.          IF INSTR(File$, "\") THEN
  586.                  EXIT FOR
  587.          ELSE
  588.                 File$ = MID$(Temp$, n)
  589.                 IF LEN(File$) >= 8 THEN EXIT FOR
  590.          END IF
  591. NEXT n
  592.  
  593. 'fifth add a backslash to the file name
  594.  
  595. IF INSTR(File$, "\") = 0 THEN
  596. File$ = "\" + File$
  597. END IF
  598.  
  599. END SUB
  600.  
  601. SUB ReadText (FileName$)
  602. ' Key code numbers, use CVI function
  603.   CONST UPARROW = 18432
  604.   CONST DOWNARROW = 20480
  605.   CONST PGUP = 18688
  606.   CONST PGDN = 20736
  607.   CONST HOME = 18176
  608.   CONST ENDKEY = 20224
  609.   CONST ESCAPE = 27
  610.  
  611. ' Functions
  612. '  DECLARE FUNCTION KeyCode% ()
  613.  
  614. ' Subprograms
  615. '  DECLARE SUB FileRead (FileName$, lineCount%, a$())
  616. '  DECLARE SUB ParseWords (FileName$, Drive$, File$, Ext$)
  617.  
  618. ' Dimension string array
  619.   DIM a$(1 TO 2000)
  620.    
  621. CALL ParseWords(FileName$, Drive$, File$, Ext$)
  622.  
  623. CALL FileRead(FileName$, LineCount%, a$())
  624.  
  625. ' Screen zero
  626.   SCREEN 0
  627.  
  628. ' Check for monochrome monitor, if true set colors for monochrome
  629.  
  630. DEF SEG = 0
  631. IF PEEK(&H463) = &HB4 THEN        '--PEEK to See Type of Monitor
  632.         DEF SEG = &HB000          '--MonoChrome Monitor(Memory Location)
  633.         Colr = 7
  634.         inverse = 112
  635.         BEEP
  636.         ELSE
  637.         Colr = 23
  638.         inverse = 48
  639.         DEF SEG = &HB800          '--Color Monitor(Memory Location)
  640. END IF
  641.  
  642. CLS
  643.  
  644. CALL CursorOff
  645.  
  646. ' Set line pointer
  647.         linePtr% = 1
  648.  
  649.  
  650. ' Main loop
  651. DO
  652.  
  653. ' Print information bar at top
  654.  
  655.         CALL PDQPrint(" Line:" + LEFT$(STR$(linePtr%) + SPACE$(6), 7) + "File: " + LEFT$(Drive$ + File$ + Ext$ + SPACE$(19), 19) + "Quit: {Esc}" + SPACE$(1) + "Move: " + CHR$(24) + " " + CHR$(25) + "  PgUp PgDn Home End ", 1, 1, inverse)
  656.  
  657.         FOR i% = 0 TO 23
  658.  
  659.             CALL PDQPrint(LEFT$(a$(i% + linePtr%) + SPACE$(80), 80), i% + 2, 1, Colr)
  660.  
  661.         NEXT i%
  662.  
  663. ' Wait for a meaningful key to be pressed
  664.  
  665. SELECT CASE KeyCode%
  666.         CASE UPARROW
  667.             IF linePtr% > 1 THEN
  668.                 linePtr% = linePtr% - 1
  669.             END IF
  670.         CASE DOWNARROW
  671.             IF linePtr% < LineCount% THEN
  672.                 linePtr% = linePtr% + 1
  673.             END IF
  674.         CASE PGUP
  675.             IF linePtr% > 1 THEN
  676.                 linePtr% = linePtr% - 24
  677.                 IF linePtr% < 1 THEN
  678.                     linePtr% = 1
  679.                 END IF
  680.             END IF
  681.         CASE PGDN
  682.             IF linePtr% < LineCount% - 24 THEN
  683.                 linePtr% = linePtr% + 24
  684.                 IF linePtr% > LineCount% THEN
  685.                     linePtr% = LineCount%
  686.                 END IF
  687.             END IF
  688.         CASE HOME
  689.             IF linePtr% > 1 THEN
  690.                 linePtr% = 1
  691.             END IF
  692.         CASE ENDKEY
  693.             IF linePtr% < LineCount% - 24 THEN
  694.                 linePtr% = LineCount% - 24
  695.             END IF
  696.         CASE ESCAPE
  697.             quitFlag% = True
  698.         CASE ELSE
  699.             updateFlag% = False
  700.         END SELECT
  701.      
  702.     LOOP UNTIL quitFlag%
  703. END SUB
  704.  
  705. SUB ScreenOne (row2, col2)
  706. COLOR 15, 1
  707. CLS
  708. LOCATE 4, 1
  709. PRINT "       "; : COLOR 15, 4: PRINT "█▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█";
  710. COLOR 15, 1: PRINT "        "; : PRINT "       ";
  711. COLOR 15, 4: PRINT "█                "; : COLOR 14, 4: PRINT "Hard Drive Partition Calculator   ";
  712. COLOR 15, 4: PRINT "             █"; : COLOR 7, 0: PRINT " ";
  713. COLOR 15, 1: PRINT "       "; : PRINT "       ";
  714. COLOR 15, 4: PRINT "█         "; : COLOR 14, 4: PRINT " ";
  715. COLOR 15, 4: PRINT "   Use to determine Optimal Cluster size          ";
  716. COLOR 14, 4: PRINT " "; : COLOR 15, 4: PRINT "  █";
  717. COLOR 15, 0: PRINT " "; : COLOR 15, 1: PRINT "       ";
  718. PRINT "       "; : COLOR 15, 4: PRINT "█";
  719. COLOR 14, 4: PRINT "         "; : COLOR 15, 4: PRINT "   For Hard Drives of 127 to 2921 ";
  720. COLOR 10, 4: PRINT "Megabytes"; : COLOR 15, 4: PRINT "     ";
  721. COLOR 14, 4: PRINT "      "; : COLOR 15, 4: PRINT "█";
  722. COLOR 15, 0: PRINT " "; : COLOR 15, 1: PRINT "       ";
  723. PRINT "       "; : COLOR 15, 4: PRINT "█                                                               █";
  724. COLOR 15, 0: PRINT " "; : COLOR 15, 1: PRINT "       ";
  725. PRINT "       "; : COLOR 15, 4: PRINT "█         Enter the SIZE in ";
  726. COLOR 14, 4: PRINT "MEGABYTES"; : COLOR 15, 4: PRINT " of your HARD";
  727. COLOR 11, 4: PRINT " "; : COLOR 15, 4: PRINT "DRIVE        █";
  728. COLOR 15, 0: PRINT " "; : COLOR 15, 1: PRINT "       ";
  729. PRINT "       "; : COLOR 15, 4: PRINT "█";
  730. COLOR 11, 4: PRINT "───────────────────────────────────────────────────────────────";
  731. COLOR 15, 4: PRINT "█"; : COLOR 15, 0: PRINT " ";
  732. COLOR 15, 1: PRINT "       "; : PRINT "       ";
  733. COLOR 15, 4: PRINT "█                                                               █";
  734. COLOR 15, 0: PRINT " "; : COLOR 15, 1: PRINT "       ";
  735. PRINT "       "; : COLOR 15, 4: PRINT "█";
  736. COLOR 14, 4: PRINT "     "; : COLOR 15, 4: PRINT "   ";
  737. COLOR 14, 4: PRINT "  "; : COLOR 15, 4: PRINT " ";
  738. COLOR 10, 4: PRINT "Hard Drive Size:"; : COLOR 15, 4: PRINT " ";
  739. row2 = CSRLIN
  740. col2 = POS(0)
  741. COLOR 7, 0: PRINT "    "; : COLOR 15, 4: PRINT "   ";
  742. COLOR 14, 4: PRINT " 1 to 4 numbers... ONLY! ";
  743. COLOR 15, 4: PRINT "   █"; : COLOR 7, 0: PRINT " ";
  744. COLOR 15, 1: PRINT "       "; : PRINT "       ";
  745. COLOR 15, 4: PRINT "█        "; : COLOR 14, 4: PRINT "  ";
  746. COLOR 15, 4: PRINT "                       ";
  747. COLOR 14, 4: PRINT " "; : COLOR 15, 4: PRINT "  ";
  748. COLOR 14, 4: PRINT "Please               ";
  749. COLOR 10, 4: PRINT "  "; : COLOR 14, 4: PRINT " ";
  750. COLOR 15, 4: PRINT "   █"; : COLOR 15, 0: PRINT " ";
  751. COLOR 15, 1: PRINT "       "; : PRINT "       ";
  752. COLOR 15, 4: PRINT "█          "; : COLOR 14, 4: PRINT "                          No Commas NO periods  ";
  753. COLOR 15, 4: PRINT "     █"; : COLOR 15, 0: PRINT " ";
  754. COLOR 15, 1: PRINT "       "; : PRINT "       ";
  755. COLOR 15, 4: PRINT "█    "; : COLOR 14, 4: PRINT "      ";
  756. COLOR 15, 4: PRINT "         "; : COLOR 14, 4: PRINT "                        ";
  757. COLOR 15, 4: PRINT "                    █";
  758. COLOR 15, 0: PRINT " "; : COLOR 15, 1: PRINT "       ";
  759. PRINT "       "; : COLOR 15, 4: PRINT "█          ";
  760. COLOR 14, 4: PRINT "         "; : COLOR 15, 4: PRINT "(PRESS {Enter when done)";
  761. COLOR 14, 4: PRINT "        "; : COLOR 15, 4: PRINT "            █";
  762. COLOR 7, 0: PRINT " "; : COLOR 15, 1: PRINT "       ";
  763. PRINT "       "; : COLOR 15, 4: PRINT "█▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█";
  764. COLOR 15, 0: PRINT " "; : COLOR 15, 1: PRINT "       ";
  765. PRINT "         "; : COLOR 7, 0: PRINT "              ";
  766. COLOR 8, 0: PRINT "John De Palma on CompuServe 76076,571   ";
  767. COLOR 7, 0: PRINT "          "; : COLOR 15, 1: PRINT "       ";
  768. END SUB
  769.  
  770. SUB ScreenOpen
  771. COLOR 15, 1
  772. LOCATE row%, 1
  773. PRINT "          ▐▐▐▐    ▐▐▐                      ▐                                    ";
  774. PRINT "         ▐▐  ▐▐    ▐▐                     ▐▐                                    ";
  775. PRINT "        ▐▐         ▐▐   ▐▐  ▐▐    ▐▐▐▐▐  ▐▐▐▐▐   ▐▐▐▐   ▐▐ ▐▐▐   ▐▐▐▐▐          ";
  776. PRINT "        ▐▐         ▐▐   ▐▐  ▐▐   ▐▐       ▐▐    ▐▐  ▐▐   ▐▐▐ ▐▐ ▐▐              ";
  777. PRINT "        ▐▐         ▐▐   ▐▐  ▐▐    ▐▐▐▐    ▐▐    ▐▐▐▐▐▐   ▐▐  ▐▐  ▐▐▐▐           ";
  778. PRINT "         ▐▐  ▐▐    ▐▐   ▐▐  ▐▐       ▐▐   ▐▐ ▐  ▐▐       ▐▐         ▐▐          ";
  779. PRINT "          ▐▐▐▐    ▐▐▐▐   ▐▐▐ ▐▐  ▐▐▐▐▐     ▐▐    ▐▐▐▐   ▐▐▐▐    ▐▐▐▐▐           ";
  780. PRINT "                                                                                ";
  781.  
  782. END SUB
  783.  
  784. SUB SetBorder (ColrByte%) STATIC
  785. DIM Regs AS RegType
  786. Regs.AX = &H1001
  787. Regs.BX = ColrByte% * &H100
  788. CALL Interrupt(&H10, Regs)
  789. END SUB
  790.  
  791. SUB ToPrint (Mega%, ClusterSize%)
  792.  
  793. DIM Drive$(24)
  794.  
  795. FOR num = 1 TO 24
  796.         Drive$(num) = CHR$(66 + num)
  797. '       PRINT Drive$(num)
  798. NEXT num
  799. 'STOP
  800. CR$ = CHR$(13) + CHR$(10)
  801. Page$ = CHR$(12)
  802. 'Mega% = 126
  803. 'ClusterSize% = 4096
  804. 'CALL BLPrint(1, X$ + CR$ + Page$, errcount)
  805.  
  806.  
  807. SELECT CASE Mega%
  808.         CASE 1 TO 127
  809.         FOR n = 1 TO 2
  810.         text$ = ""
  811.         CALL BLPrint(1, text$ + CR$, ErrCount)
  812.         NEXT
  813.                         SELECT CASE ClusterSize%
  814.                         CASE 2048
  815.                         text$ = STRING$(10, 32) + "You Really don't need my help...."
  816.                         CALL BLPrint(1, text$ + CR$, ErrCount)
  817.                         text$ = STRING$(10, 32) + "Hard Disk Size is: " + STR$(Mega%)
  818.                         CALL BLPrint(1, text$ + CR$, ErrCount)
  819.                         text$ = STRING$(10, 32) + "Cluster Size is:" + STR$(ClusterSize%)
  820.                         CALL BLPrint(1, text$ + CR$, ErrCount)
  821.                      
  822.                         CASE 4096 TO 8916
  823.                         text$ = STRING$(10, 32) + "USE FDISK.EXE with DOS 5.0 or Better...."
  824.                         CALL BLPrint(1, text$ + CR$, ErrCount)
  825.                         text$ = STRING$(10, 32) + "Hard Disk Size is: " + STR$(Mega%)
  826.                         CALL BLPrint(1, text$ + CR$, ErrCount)
  827.                         text$ = STRING$(10, 32) + "Cluster Size is:" + STR$(ClusterSize%)
  828.                         CALL BLPrint(1, text$ + CR$, ErrCount)
  829.                         CASE ELSE
  830.                         text$ = STRING$(10, 32) + "MISTAKE HERE..."
  831.                         CALL BLPrint(1, text$ + CR$, ErrCount)
  832.                         END SELECT
  833.       
  834.          CASE 128 TO 2921
  835.                
  836.                 text$ = ""
  837.                 CALL BLPrint(1, text$ + CR$, ErrCount)
  838.                 text$ = STRING$(20, 32) + "HARD DISK size to PARTITION is:[" + STR$(Mega%) + " ] MegaBytes"
  839.                 CALL BLPrint(1, text$ + CR$, ErrCount)
  840.                 text$ = ""
  841.                 CALL BLPrint(1, text$ + CR$, ErrCount)
  842.                 text$ = STRING$(20, 32) + "DRIVE LETTER" + STRING$(10, 32) + "Drive Size in MB"
  843.                 CALL BLPrint(1, text$ + CR$, ErrCount)
  844.                 text$ = STRING$(10, 32) + STRING$(60, "_")
  845.                 CALL BLPrint(1, text$ + CR$, ErrCount)
  846.                 text$ = ""
  847.                 CALL BLPrint(1, text$ + CR$, ErrCount)
  848.  
  849.                 NumberDrives% = Mega% \ 127
  850.                 IF Mega% MOD 127 <> 0 THEN
  851.                         NumberDrives% = NumberDrives% + 1
  852.                 END IF
  853.                 Temp% = Mega%
  854.                 FOR n = 1 TO NumberDrives%
  855.                 LOCATE row% + n, 20
  856. 'STOP
  857.                 SELECT CASE Temp%
  858.  
  859.                         CASE IS > 127 + 15
  860.                         DriveSize = 127
  861.                         CASE IS < 127
  862.                                 DriveSize = Temp%
  863.                         CASE 127
  864.                                 DriveSize = 127
  865.                         CASE IS < 127 + 16
  866.                                 DriveSize = 127 - 16 + (Temp% MOD 127)
  867.                         CASE ELSE
  868.                         PRINT Temp%
  869.                         BEEP
  870.                         PRINT "BIG MISTAKE!... probably mine"
  871.                         STOP
  872.                END SELECT
  873.            
  874.  
  875.                 text$ = STRING$(20, 32) + "Drive: " + Drive$(n) + STRING$(17, 32) + STR$(DriveSize)
  876.                 CALL BLPrint(1, text$ + CR$, ErrCount)
  877.                
  878.                 Temp% = Temp% - DriveSize
  879.                 NEXT n
  880.         CASE ELSE
  881.            text$ = ""
  882.            FOR n = 1 TO 10
  883.            CALL BLPrint(1, text$ + CR$, ErrCount)
  884.            NEXT
  885.            text$ = "Uh...." + STR$(Mega%) + " MB is -TOO BIG A DRIVE- to measure...."
  886.            CALL BLPrint(1, text$ + CR$, ErrCount)
  887. END SELECT
  888. FOR n = 1 TO 2
  889. text$ = ""
  890. CALL BLPrint(1, text$ + CR$, ErrCount)
  891. NEXT
  892. text$ = STRING$(25, 32) + "John De Palma on CompuServe 76076,571"
  893. CALL BLPrint(1, text$ + CR$, ErrCount)
  894. FOR n = 1 TO 2
  895. text$ = ""
  896. CALL BLPrint(1, text$ + CR$, ErrCount)
  897. NEXT
  898. text$ = STRING$(10, 32) + "Printing Line feed..."
  899. CALL BLPrint(1, text$ + CR$ + Page$, ErrCount)
  900.  
  901. END SUB
  902.  
  903. SUB WannaPrint (Mega%, ClusterSize%)
  904. COLOR 11, 0
  905. col4 = 50
  906. 'STOP
  907. LOCATE row% + 1, col4
  908. PRINT "╒══════════════════════════╕"
  909. LOCATE row% + 2, col4
  910. PRINT "│   PRINT THIS OUTPUT ?    │"
  911. LOCATE row% + 3, col4
  912. PRINT "│                          │"
  913. LOCATE row% + 4, col4
  914. PRINT "│   PRESS  'Y' to Print    │"
  915. LOCATE row% + 5, col4
  916. PRINT "│                          │"
  917. LOCATE row% + 6, col4
  918. PRINT "│  any other key to EXIT   │"
  919. LOCATE row% + 7, col4
  920. PRINT "│                          │"
  921. LOCATE row% + 8, col4
  922. PRINT "╘══════════════════════════╛"
  923. LOCATE row% + 7, col4 + 12, 1, 4, 7
  924.  
  925. 'STOP
  926. IF Choice(YN$) THEN
  927. CALL ToPrint(Mega%, ClusterSize%)
  928. ELSE
  929. END IF
  930. END SUB
  931.  
  932. SUB WhereIsHelpFile (FileName$)
  933. Drive$ = CHR$(GetDrive%) + ":"
  934. ThisDir$ = GetDir$(Drive$)
  935. 'FileName$ = "CLUSTER.DOC"
  936. IF NOT Exist%(FileName$) THEN
  937. SetBorder (4)
  938. BEEP
  939. text$ = "  »»»  " + FileName$ + "  «««  "
  940. LOCATE row% + 2, Center(text$)
  941. COLOR 14, 6
  942. PRINT text$
  943. COLOR 15, 1
  944. text$ = "Can't Find The  »» HELP FILE «« in This Directory!"
  945. LOCATE row% + 6, Center(text$)
  946. PRINT text$
  947. text$ = "This Drive & Directory is: "
  948. LOCATE row + 8, Center(text$)
  949. COLOR 11, 1
  950. PRINT text$
  951. text$ = Drive$ + ThisDir$
  952. LOCATE row + 10, Center(text$)
  953. COLOR 11, 0
  954. PRINT text$
  955. COLOR 15, 1
  956. text$ = "Sorry... We need that file, Ending Program... "
  957.  
  958. LOCATE row + 12, Center(text$)
  959. PRINT text$
  960. FiveSeconds = 5 * 18
  961. PAUSE (FiveSeconds)
  962. SetBorder (0)
  963. text$ = " Please Copy " + FileName$ + " to this Directory "
  964. LOCATE row + 14, Center(text$)
  965. COLOR 11, 0
  966. PRINT " Please Copy ";
  967. COLOR 15, 0
  968. PRINT FileName$;
  969. COLOR 11, 0
  970. PRINT " to this Directory "
  971. BEEP
  972. END
  973. END IF
  974.  
  975. END SUB
  976.  
  977. 'This file was last compiled with:
  978. 'BC C:\QB45\PDQ\CLUSTER.BAS  /o;
  979. 'LINK CLUSTER+
  980. '     C:\QB45\PDQ\_CPRINT+
  981. '     /nod /noe /packcode /far
  982. '
  983. '     nul
  984. '     C:\QB45\PDQ\PRO C:\QB45\PDQ\PDQ
  985. 'This file was last compiled with:
  986. 'BC C:\QB45\PDQ\CLUSTER.BAS  /o;
  987. 'LINK CLUSTER+
  988. '     C:\QB45\PDQ\_CPRINT+
  989. '     /nod /noe /packcode /far
  990. '
  991. '     nul
  992. '     C:\QB45\PDQ\PRO C:\QB45\PDQ\PDQ
  993.